package com.chenyongjing.design.pattern.strategy.pay;

import com.chenyongjing.design.pattern.strategy.pay.payport.MsgResult;
import com.chenyongjing.design.pattern.strategy.pay.payport.Payment;

/**
 * @Author chen
 * @Date 2022/11/13 22:02
 */
public class Order {
    private String uid;
    private String orderId;
    private double amount;

    public Order(String uid, String orderId, double amount) {
        this.uid = uid;
        this.orderId = orderId;
        this.amount = amount;
    }
    public MsgResult pay(){
        return pay(PayStrategy.DEFAULT_PAY);
    }


    public MsgResult pay(String payStrategyKey){
        Payment payment = PayStrategy.get(payStrategyKey);
        System.out.println("欢迎使用"+payment.getName());
        System.out.println("本次交易金额"+amount+"，开始扣款....");
        return payment.pay(uid,amount);
    }
}
